package junitTest.juniTest01;

import java.sql.SQLException;

import objectFactory.UserDao;

import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static  org.junit.Assert.assertThat;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;


import vo.UserVO;

public class UserDaoTest {
	@Test
	public void addAndGet() throws SQLException,ClassNotFoundException{
		ApplicationContext context = new GenericXmlApplicationContext("applicationContext.xml");
		UserDao userDao= context.getBean("userDao",UserDao.class);
		UserVO user = new UserVO();
		user.setId("junit1");
		user.setPassword("junit1");
		user.setName("junit1");
		
		userDao.add(user);
		
		UserVO user2 = userDao.get(user.getId());
		
		assertThat(user2.getName(),is(user.getName()));
		
		assertThat(user2.getPassword(),is(user.getPassword()));
		
	}
}
